package com.voxel.sense.infomsg.view;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.com.common.utils.SizeUtils;
import com.voxel.sense.infomsg.R;


/**
 * recyclerView中item之间的上下左右边距
 */
public class TaskChecktemDivider extends RecyclerView.ItemDecoration {
    private int space = SizeUtils.dp2px(2);


    public TaskChecktemDivider() {
    }

    public TaskChecktemDivider(int space) {
        this.space = space;
    }


    /**
     * 设置内部item的偏移量
     */
    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        int position = parent.getChildAdapterPosition(view);
        RecyclerView.Adapter adapter = parent.getAdapter();

        if (adapter.getItemViewType(position) == R.layout.item_recycler_task_file) {
            outRect.left = space;
            outRect.right = space;
        } else if (adapter.getItemViewType(position) == R.layout.item_recycler_layout_report_list || position == 0) {
            outRect.bottom = space;
        }


    }
}
